<?
$tb = "pro_category";

$Query = "select name ,code ,id,cname,publish from $tb WHERE level=0 order by sort,id";
$r = myQuery($Query);

$Query = "select name, parent ,code ,id,cname,publish from $tb WHERE level=1 order by sort,id";
$r1 = myQuery($Query);

$Query = "select name, parent ,code ,id,cname,publish from $tb WHERE level=2 order by sort,id";
$r2 = myQuery($Query);

$sourceData = array();
$sourceLabel = array();
$sourceId	= array();
$sourcePub	= array();

for ($i=0;$i<count($r);$i++){

	array_push($sourceData,$r[$i][0].' '.$r[$i][3]);
	array_push($sourceLabel,$r[$i][1]);
	array_push($sourceId,$r[$i][2]);
	array_push($sourcePub,$r[$i][4]);
	
	for ($n=0;$n<count($r1);$n++){

		if ($r[$i][2]==$r1[$n][1]){

			array_push($sourceData,"&nbsp;<font color=\"blue\">&#8226;</font>&nbsp;&nbsp;" . $r1[$n][0].' '.$r1[$n][4]);
			array_push($sourceLabel, $r1[$n][2] );
			array_push($sourceId,$r1[$n][3]);
			array_push($sourcePub,$r1[$n][5]);

			for ($m=0;$m<count($r2);$m++){

			if ($r1[$n][3]==$r2[$m][1]){

				array_push($sourceData,"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color=\"red\">&#8226;&#8226;</font>&nbsp;&nbsp;" .$r2[$m][0].' '.$r2[$m][4]);
				array_push($sourceLabel, $r2[$m][2] );
				array_push($sourceId,$r2[$m][3]);
				array_push($sourcePub,$r2[$m][5]);
				
			}
			}

		}
	}

}



?>
<form name="form1" method="post" action="../../inc/mod_pub_category.php">
		<input type="hidden" name="nonew" value="1">


        <table width="100%" border="0" cellspacing="1" cellpadding="1" class="tb">
          <tr class="tbheader"> 
            <td width="20%">Code</td>
            <td width="50%">Name</td>
            <td width="10%">Publish ?</td>
			<td width="20%"></td>
          </tr>
          <tr class="tbcontent1"> 
            <td></td>
            <td></td>
            <td><div align="center">
              <input type="submit" name="submit" value="Save">
            </div></td>
			<td></td>
          </tr>


<?
if ($sourceLabel){
	for ($i=0;$i<count($sourceLabel);$i++){?>
          <tr class="tbcontent1"> 
            <td><?print($sourceLabel[$i])?></td>
            <td align="left"><?print($sourceData[$i])?></td>
            <td align="left"><div align="center">
              <input name="pub[<?=$sourceId[$i]?>]" type="radio" id="pub[<?=$sourceId[$i]?>]" value="1" <? echo $sourcePub[$i]?"checked":"";?>> Y 
              <input name="pub[<?=$sourceId[$i]?>]" type="radio" id="pub[<?=$sourceId[$i]?>]" value="0" <? echo !$sourcePub[$i]?"checked":"";?>> N 
            </div></td>
			<td align=center bgcolor="ECECEC">
			<a href="edit.php?Start_Num=<?echo $Start_Num?>&id=<?print($sourceId[$i])?>"><img src="<?print($rela_path)?>images/bt_edit.gif" border="0" alt="Edit"></a>
			<a href="delete.php?id=<?print($sourceId[$i])?>"><img src="<?print($rela_path)?>images/bt_delete.gif" border="0" Alt="Delete"></a>
			<a href="enquire.php?id=<?print($sourceId[$i])?>"><img src="<?print($rela_path)?>images/bt_enquiry.gif" border="0" Alt="Enquire"></a></td>
          </tr>
<?
	}
?>
          <tr class="tbcontent1"> 
            <td></td>
            <td></td>
            <td><div align="center">
              <input type="submit" name="submit" value="Save">
			  <input type="hidden" name="url" value="../product/category/category_menu.php">
			  <input type="hidden" name="table" value="<?=$tb?>">
            </div></td>
			<td></td>
          </tr>

<?
}
?>


        </table>

</form>